package com.example.p3;

import java.util.Scanner;

public class Employee {
    private String name;
    private int age;
    private String designation;
    private double salary;

    //Employee类的构造器
    public Employee(String name) {
        this.name = name;
    }

    //设置age的值
    public void setAge(int age) {
        this.age = age;
    }

    //获取age的值
    public int getAge() {
        return age;
}

//设置designation的值
    public void setDesignation(String designation) {
        this.designation = designation;
    }

    //获取designation的值
    public String getDesignation() {
        return designation;
    }

    //设置salary的值
    public void setSalary(double salary) {
        this.salary = salary;
    }

    //获取salary的值
    public double getSalary() {
        return salary;
    }

    //打印信息
    public void printEmployee() {
        System.out.println(this);
    }

    //重写toString方法
    @Override
    public String toString() {
        return "名字: " + name + "\n" +
                "年龄: " + age + "\n" +
                "职位: " + designation + "\n" +
                "薪水: " + salary;
    }

}

